//
//  PSWJoinGroupVC.m
//  AAIM
//
//  Created by awh on 2019/12/14.
//  Copyright © 2019年 AAIM. All rights reserved.
//

#import "PSWJoinGroupVC.h"
#import "HWTFCursorView.h"
#import "ContactRequestLogic.h"
#import "ChatViewController.h"
@interface PSWJoinGroupVC ()<HWTFCursorViewDelegate>

@property (nonatomic, strong) HWTFCursorView *codeView;
@end

@implementation PSWJoinGroupVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.gk_navTitle=@"口令进群";
    UILabel *titlelbl = [UILabel new];
    titlelbl.textColor = [UIColor orangeColor];
    titlelbl.font = [UIFont boldSystemFontOfSize:15];
    titlelbl.text = @"输入口令进入群聊";
    titlelbl.textAlignment=1;
    titlelbl.textColor=KHEXCOLOR(@"#262B2F");
    titlelbl.frame = CGRectMake(20, NavigationBarHeight+80, SCREEN_WIDTH-40, 20);
    [self.view addSubview:titlelbl];
    
    _codeView = [[HWTFCursorView alloc] initWithCount:4 margin:20];
    _codeView.backgroundColor=[UIColor redColor];
    _codeView.delegate=self;
    _codeView.frame = CGRectMake(30,titlelbl.bottom+60 , SCREEN_WIDTH-60, 50);
    [self.view addSubview:self.codeView];
    // Do any additional setup after loading the view.
}
-(void)textCode:(NSString *)code
{
    [ContactRequestLogic requestJoinGroupSetWithGroupId:@"" GroupCode:code fuuids:[LoginManager shareLoginManager].userModel.uuid reason:@"" type:@"2" Success:^(NSDictionary * _Nonnull Dict) {
        NSLog(@"加群成功%@",Dict);
//        3s跳转群聊
//        KWeakSelf;
        [self showTipHudWithText:@"加群成功，等待群主审核"];
//        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
//            [weakSelf hideHud];
//            ChatViewController * vc =[[ChatViewController alloc]init];
////            vc.type=@"group";
//            vc.chatType=ChatTypeGroup;
////            vc.receiverId=000000;
//            [self.navigationController pushViewController:vc animated:YES];
//        });
        
    } failure:^(NSString * _Nonnull errMsg) {
        [self showTipHudWithText:@"该口令不存在或已失效"];
    }];
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
